<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>Title</title>
</head>
<body>
    <!--<footer  th:fragment="footer" class="layui-footer">-->
    <footer  th:fragment="footer"  class="layui-footer">
        <!-- 底部固定区域 -->
        <div class="layui-main" style="text-align: center">
            <p>蜀ICP备19013873号</p>
        </div>

        <!-- JavaScript -->
        <script src="/static/layui/layui.js" th:src="@{/layui/layui.js}" charset="utf-8"></script>
        <script src="/static/step/step.js" th:src="@{/step/step.js}" charset="utf-8"></script>
        <script src="/static/date_xiyang.js" th:src="@{/date_xiyang.js}" charset="utf-8"></script>
        <script src="/static/jquery/jquery-3.2.1.min.js" th:src="@{/jquery/jquery-3.2.1.min.js}" charset="utf-8"></script>
        <script th:inline="javascript">
            /*<![CDATA[*/

            $(document).ready(function(){
                $(document).ajaxError(function(event,xhr,options,exc){
                    switch(xhr.status) {
                        case(500):
                            alert("服务器系统内部错误");
                            break;
                        case(401):
                            window.location.href="/index";
                            break;
                        case(403):
                            alert("无权限执行此操作");
                            break;
                        case(408):
                            alert("请求超时");
                            break;
                        // default:
                        //     alert("未知错误");
                    }
                });
            });


            const {log} = console;

            const page = {init:null}; /* 用于保存layui之外的变量 */

            layui.config({
                base: '/step/' /* 注意末尾一定要打/ */
            });

            layui.config({
                base: '/layui/extend/' /* 注意末尾一定要打/ */
            }).extend({ //设定组件别名
                nav: 'nav/nav', //如果 mymod.js 是在根目录，也可以不用设定别名 //相对于上述 base 目录的子目录
                preOrder: 'preOrder/preOrder'
            });


            layui.use(['element','layer'], function(){
                let element = layui.element;
                //监听右导行
                element.on('nav(right)', function(elem){
                    log(elem);
                    if(elem[0].id==='logout')
                        return;
                    if(elem[0].childElementCount!==0)
                        return;
                    let dom = $(""+"#"+elem[0].id+"");
                    dom.parent().addClass('layui-this');
                    $.get(dom.data("href"), function(data,status){
                        $("#body").html(data);
                    });
                });

                //监听导航点击
                element.on('nav(test)', function(elem){
                    if(elem[0].childElementCount===2||elem[0].childElementCount===0)
                    $.get(elem[0].id, function(data,status){
                        $("#body").empty();
                        $("#body").html(data);
                        //location.hash = 'nav=' + $(elem[0]).parent().attr("id");
                        let index = location.hash.indexOf("tab=");
                        if(index !== -1){
                            let layid = location.hash.substring(index+4);
                            location.hash ='nav=' + $(elem[0]).parent().attr("id")+"#tab="+layid;
                        }else location.hash = 'nav=' + $(elem[0]).parent().attr("id")
                    });
                });
            });
            /*]]>*/
        </script>
    </footer>
</body>
</html>